package org.tinygroup.bizframe.scantest;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.tinygroup.logger.Logger;
import org.tinygroup.logger.LoggerFactory;
import org.tinygroup.springutil.PathMatchingInJarResourcePatternResolver;

public class PathMathingScaner implements InitializingBean{

    private static final Logger logger = LoggerFactory.getLogger(PathMathingScaner.class);

    private PathMatchingInJarResourcePatternResolver pathMatchingInJarResourcePatternResolver;

    private PathMatchingResourcePatternResolver pathMatchingResourcePatternResolver;


    private String scanResource;

    public void setPathMatchingInJarResourcePatternResolver(PathMatchingInJarResourcePatternResolver pathMatchingInJarResourcePatternResolver) {
        this.pathMatchingInJarResourcePatternResolver = pathMatchingInJarResourcePatternResolver;
    }

    public void setPathMatchingResourcePatternResolver(PathMatchingResourcePatternResolver pathMatchingResourcePatternResolver) {
        this.pathMatchingResourcePatternResolver = pathMatchingResourcePatternResolver;
    }

    public void setScanResource(String scanResource) {
        this.scanResource = scanResource;
    }

    public void afterPropertiesSet() throws Exception {
        Resource[] springResources = pathMatchingResourcePatternResolver.getResources(scanResource);
        logger.warn("spring pathMatchingResourcePatternResolver找到资源个数:"+springResources.length);

        Resource[] tinyResouces = pathMatchingInJarResourcePatternResolver.getResources(scanResource);
        logger.warn("tiny pathMatchingInJarResourcePatternResolver找到资源个数:"+tinyResouces.length);

    }
}
